package com.DAOTest;

import junit.framework.Assert;
import junit.framework.TestCase;

import org.junit.Test;
import com.dao.*;
import com.beans.Movie;
import com.beans.Person;
import com.bussiness.PersonBussiness;
import com.exceptions.DeleteCustomerWithOutstandingMovieException;
import com.exceptions.DuplicateUserIdException;
import com.exceptions.InvalidCustomerNameException;
import com.exceptions.InvalidEmailException;
import com.exceptions.InvalidUserNamePasswordException;
import com.exceptions.MinimumPwdLengthException;
import com.exceptions.MovieAlreadyDeletedException;
import com.exceptions.MovieAlreadyExistsException;
import com.exceptions.PasswordNotMatchingException;
import com.exceptions.ServiceUnavailableException;
import com.exceptions.UserCartIsEmptyException;
import com.exceptions.UserException;
import com.sun.org.apache.xml.internal.security.utils.Base64;

public class PersonDAOTest
{
	public PersonDAOTest()
	{
		super();
		System.out.println("i can execute");
	}
	
	@Test
	public void createUser_9() throws Exception 
	{
		//testing the create user with correct parameters
		Person person = new Person();
		Person actualPerson= null;
		PersonBussiness personBI = new PersonBussiness();
		PersonDAO persondao=new PersonDAO();
		java.util.Date s1=new java.util.Date();
		String movielist = null;
		 int movielimit =0, issuedmovie =0;
		 double rent = 0;
		 int i=0;
			 person.setFirstName("Charlie");
			 person.setLastName("Harper");
			 person.setAddress("th Street # Polar express Road");
			 person.setCity("Milpitas");
			 person.setState("KY");
			 person.setZipCode(61298);
			 person.setEmailId("test100@gmail.com");
				byte[] encryptedpwd = personBI.encryptPassword("cipher123");
				person.setPassword(Base64.encode(encryptedpwd));
			 person.setCustomerType("S");
			 person.setMovieLimit(2);
			 person.setBalance(0.0);
			 person.setIssuedMovies(0);
			 person.setIssuedMoviesList("");

			 try 
			 {
				 actualPerson = persondao.createUser(person);
			 } 
			 catch(DuplicateUserIdException duplicate)
			 {
				 System.out.println(duplicate.toString());
			 }
			 catch(ServiceUnavailableException serv)
			 {
				 System.out.println(serv.toString());
			 }
			 catch(InvalidEmailException inv)
			 {
				 System.out.println(inv.toString());
			 }
			 catch(MinimumPwdLengthException min)
			 {
				 System.out.println(min.toString());
			 }
			 catch(InvalidCustomerNameException invcust)
			 {
				 System.out.println(invcust.toString());
			 }

	}
	
	@Test
	public void createUser_10() throws Exception
	{
		//testing for password validity
		  	Person person = new Person();
			Person actualPerson= null;
			PersonDAO persondao=new PersonDAO();

			PersonBussiness personBI = new PersonBussiness();
			java.util.Date s1=new java.util.Date();
			 person.setFirstName("Miniature");
			 person.setLastName("Database");
			 person.setAddress("th Street # Mint Candy Road");
			 person.setCity("Santa Clara");
			 person.setState("CA");
			 person.setZipCode(54356);
			 person.setEmailId("guestemail@mandolin.com");
			 byte[] encryptedpwd = personBI.encryptPassword("@@@@@");
			 person.setPassword(Base64.encode(encryptedpwd));
			 person.setCustomerType("S");
			 person.setMovieLimit(2);
			 person.setBalance(0.0);
			 person.setIssuedMovies(0);
			 person.setIssuedMoviesList("");
			 		
		try 
		{
			actualPerson = persondao.createUser(person);
		} 
		catch(DuplicateUserIdException duplicate)
		{
			System.out.println(duplicate.toString());
		}
		catch(ServiceUnavailableException serv)
		{
			System.out.println(serv.toString());
		}
		catch(InvalidEmailException inv)
		{
			System.out.println(inv.toString());
		}
		catch(MinimumPwdLengthException min)
		{
			System.out.println(min.toString());
		}
		catch(InvalidCustomerNameException invcust)
		{
			System.out.println(invcust.toString());
		}
	}
	
	@Test
	public void createUser_11() throws Exception
	{
		//checking user first name
			Person person = new Person();
			PersonDAO persondao=new PersonDAO();

			Person actualPerson= null;
			PersonBussiness personBI = new PersonBussiness();
			java.util.Date s1=new java.util.Date();
			 person.setFirstName("Minia#$@#$#ture");
			 person.setLastName("Database");
			 person.setAddress("th Street # Mint Candy Road");
			 person.setCity("Santa Clara");
			 person.setState("CA");
			 person.setZipCode(54356);
			 person.setEmailId("guestemail@mandolin.com");
			 byte[] encryptedpwd = personBI.encryptPassword("restful");
			 person.setPassword(Base64.encode(encryptedpwd));
			 person.setCustomerType("S");
			 person.setMovieLimit(2);
			 person.setBalance(0.0);
			 person.setIssuedMovies(0);
			 person.setIssuedMoviesList("");
		
		try 
		{
			actualPerson = persondao.createUser(person);
		} 
		catch(DuplicateUserIdException duplicate)
		{
			System.out.println(duplicate.toString());
		}
		catch(ServiceUnavailableException serv)
		{
			System.out.println(serv.toString());
		}
		catch(InvalidEmailException inv)
		{
			System.out.println(inv.toString());
		}
		catch(MinimumPwdLengthException min)
		{
			System.out.println(min.toString());
		}
		catch(InvalidCustomerNameException invcust)
		{
			System.out.println(invcust.toString());
		}
	}
	
	@Test
	public void createUser_12() throws Exception
	{
		//checking user first name 
			Person person = new Person();
			PersonDAO persondao=new PersonDAO();

			Person actualPerson= null;
			PersonBussiness personBI = new PersonBussiness();
			java.util.Date s1=new java.util.Date();
			 person.setFirstName("iammorethantwentycharecterslong");
			 person.setLastName("Database");
			 person.setAddress("th Street # Mint Candy Road");
			 person.setCity("Santa Clara");
			 person.setState("CA");
			 person.setZipCode(54356);
			 person.setEmailId("guestemail@mandolin.com");
			 byte[] encryptedpwd = personBI.encryptPassword("restful");
			 person.setPassword(Base64.encode(encryptedpwd));
			 person.setCustomerType("S");
			 person.setMovieLimit(2);
			 person.setBalance(0.0);
			 person.setIssuedMovies(0);
			 person.setIssuedMoviesList("");
		try 
		{
			actualPerson = persondao.createUser(person);
		} 
		catch(DuplicateUserIdException duplicate)
		{
			System.out.println(duplicate.toString());
		}
		catch(ServiceUnavailableException serv)
		{
			System.out.println(serv.toString());
		}
		catch(InvalidEmailException inv)
		{
			System.out.println(inv.toString());
		}
		catch(MinimumPwdLengthException min)
		{
			System.out.println(min.toString());
		}
		catch(InvalidCustomerNameException invcust)
		{
			System.out.println(invcust.toString());
		}
	}
	
	
	@Test
	public void createUser_13() throws Exception
	{
	//lastname validaton 
			Person person = new Person();
			PersonDAO persondao=new PersonDAO();

			Person actualPerson= null;
			PersonBussiness personBI = new PersonBussiness();
			java.util.Date s1=new java.util.Date();
			 person.setFirstName("Miniature");
			 person.setLastName("Data$%$%base");
			 person.setAddress("th Street # Mint Candy Road");
			 person.setCity("Santa Clara");
			 person.setState("CA");
			 person.setZipCode(54356);
			 person.setEmailId("guestemail@mandolin.com");
			 byte[] encryptedpwd = personBI.encryptPassword("restful");
			 person.setPassword(Base64.encode(encryptedpwd));
			 person.setCustomerType("S");
			 person.setMovieLimit(2);
			 person.setBalance(0.0);
			 person.setIssuedMovies(0);
			 person.setIssuedMoviesList("");
		
		try 
		{
			actualPerson = persondao.createUser(person);
		} 
		catch(DuplicateUserIdException duplicate)
		{
			System.out.println(duplicate.toString());
		}
		catch(ServiceUnavailableException serv)
		{
			System.out.println(serv.toString());
		}
		catch(InvalidEmailException inv)
		{
			System.out.println(inv.toString());
		}
		catch(MinimumPwdLengthException min)
		{
			System.out.println(min.toString());
		}
		catch(InvalidCustomerNameException invcust)
		{
			System.out.println(invcust.toString());
		}
	}
	
	@Test
	public void createUser_14() throws Exception
	{
		//checking user last name 
			Person person = new Person();
			PersonDAO persondao=new PersonDAO();

			Person actualPerson= null;
			PersonBussiness personBI = new PersonBussiness();
			java.util.Date s1=new java.util.Date();
			 person.setFirstName("Miniature");
			 person.setLastName("iammorethantwentycharecterslong");
			 person.setAddress("th Street # Mint Candy Road");
			 person.setCity("Santa Clara");
			 person.setState("CA");
			 person.setZipCode(54356);
			 person.setEmailId("guestemail@mandolin.com");
			 byte[] encryptedpwd = personBI.encryptPassword("restful");
			 person.setPassword(Base64.encode(encryptedpwd));
			 person.setCustomerType("S");
			 person.setMovieLimit(2);
			 person.setBalance(0.0);
			 person.setIssuedMovies(0);
			 person.setIssuedMoviesList("");
		
		try 
		{
			actualPerson = persondao.createUser(person);
		} 
		catch(DuplicateUserIdException duplicate)
		{
			System.out.println(duplicate.toString());
		}
		catch(ServiceUnavailableException serv)
		{
			System.out.println(serv.toString());
		}
		catch(InvalidEmailException inv)
		{
			System.out.println(inv.toString());
		}
		catch(MinimumPwdLengthException min)
		{
			System.out.println(min.toString());
		}
		catch(InvalidCustomerNameException invcust)
		{
			System.out.println(invcust.toString());
		}
	}
	
	@Test
	public void createUser_15() throws Exception
	{
		//checking user email 
			Person person = new Person();
			PersonDAO persondao=new PersonDAO();

			Person actualPerson= null;
			PersonBussiness personBI = new PersonBussiness();
			java.util.Date s1=new java.util.Date();
			 person.setFirstName("Miniature");
			 person.setLastName("Database");
			 person.setAddress("th Street #Mint Candy Road");
			 person.setCity("Santa Clara");
			 person.setState("CA");
			 person.setZipCode(54356);
			 person.setEmailId("guestemailmandolincom");
			 byte[] encryptedpwd = personBI.encryptPassword("restful");
			 person.setPassword(Base64.encode(encryptedpwd));
			 person.setCustomerType("S");
			 person.setMovieLimit(2);
			 person.setBalance(0.0);
			 person.setIssuedMovies(0);
			 person.setIssuedMoviesList("");
		try 
		{
			actualPerson = persondao.createUser(person);
		} 
		catch(DuplicateUserIdException duplicate)
		{
			System.out.println(duplicate.toString());
		}
		catch(ServiceUnavailableException serv)
		{
			System.out.println(serv.toString());
		}
		catch(InvalidEmailException inv)
		{
			System.out.println(inv.toString());
		}
		catch(MinimumPwdLengthException min)
		{
			System.out.println(min.toString());
		}
		catch(InvalidCustomerNameException invcust)
		{
			System.out.println(invcust.toString());
		}
	}
	
	@Test
	public void createUser_16() throws Exception
	{
		//checking password validity 
			Person person = new Person();
			PersonDAO persondao=new PersonDAO();

			Person actualPerson= null;
			PersonBussiness personBI = new PersonBussiness();
			java.util.Date s1=new java.util.Date();
			 person.setFirstName("Miniature");
			 person.setLastName("Database");
			 person.setAddress("th Street # Mint Candy Road");
			 person.setCity("Santa Clara");
			 person.setState("CA");
			 person.setZipCode(54356);
			 person.setEmailId("guestemail@mandolin.com");
			 byte[] encryptedpwd = personBI.encryptPassword("1234543523423423");
			 person.setPassword(Base64.encode(encryptedpwd));
			 person.setCustomerType("S");
			 person.setMovieLimit(2);
			 person.setBalance(0.0);
			 person.setIssuedMovies(0);
			 person.setIssuedMoviesList("");
		try 
		{
			actualPerson = persondao.createUser(person);
		} 
		catch(DuplicateUserIdException duplicate)
		{
			System.out.println(duplicate.toString());
		}
		catch(ServiceUnavailableException serv)
		{
			System.out.println(serv.toString());
		}
		catch(InvalidEmailException inv)
		{
			System.out.println(inv.toString());
		}
		catch(MinimumPwdLengthException min)
		{
			System.out.println(min.toString());
		}
		catch(InvalidCustomerNameException invcust)
		{
			System.out.println(invcust.toString());
		}
	}
	
	@Test
	public void validateUser() throws Exception
	{
		//Correct implementation of validate user
		Person person = new Person();
		person.setEmailId("test@gm.com");
		PersonDAO personDAO = new PersonDAO();
		PersonBussiness personBI = new PersonBussiness();
		byte[] encryptedpwd = personBI.encryptPassword("guest123");	
		person.setPassword(Base64.encode(encryptedpwd));
		
		Person actualPerson = null;
		
		try 
		{
			actualPerson = personDAO.validateUser(person);
		} 
		catch(InvalidUserNamePasswordException inv)
		{
			System.out.println(inv.toString());	
		}
		catch(PasswordNotMatchingException pwdntmatch)
		{
			System.out.println(pwdntmatch.toString());
		}
		catch(ServiceUnavailableException servunavl)
		{
			System.out.println(servunavl.toString());	
		}
		catch(InvalidEmailException inv)
		{
			System.out.println(inv.toString());
		}
		catch(MinimumPwdLengthException min)
		{
			System.out.println(min.toString());
		}
		Assert.assertEquals("Guest", actualPerson.getFirstName());		
		Assert.assertEquals("User", actualPerson.getLastName());
	}
	
	@Test
	public void validateUser_1() throws Exception
	{
		//invalid input
		Person person = new Person();
		person.setEmailId("test@gm.com");
		PersonDAO personDAO = new PersonDAO();
		PersonBussiness personBI = new PersonBussiness();
		byte[] encryptedpwd = personBI.encryptPassword("guess123");	
		person.setPassword(Base64.encode(encryptedpwd));
		
		Person actualPerson = null;
		
		try 
		{
			actualPerson = personDAO.validateUser(person);
		} 
		catch(InvalidUserNamePasswordException inv)
		{
			System.out.println(inv.toString());	
		}
		catch(PasswordNotMatchingException pwdntmatch)
		{
			System.out.println(pwdntmatch.toString());
		}
		catch(ServiceUnavailableException servunavl)
		{
			System.out.println(servunavl.toString());	
		}
		catch(InvalidEmailException inv)
		{
			System.out.println(inv.toString());
		}
		catch(MinimumPwdLengthException min)
		{
			System.out.println(min.toString());
		}
	}
	@Test
	public void updateUser() throws Exception
	{
		//Passing correct values
		Person person = new Person();
		person.setCustomerType("P");
		person.setFirstName("Test");
		person.setLastName("Create");
		person.setAddress("Unknown");
		person.setState("CA1");
		person.setCity("SJ1");
		person.setZipCode(95035);
		person.setEmailId("test5@gm.com");
		PersonDAO personDAO = new PersonDAO();
		PersonBussiness personBI = new PersonBussiness();
		byte[] encryptedpwd = personBI.encryptPassword("guest123");
		person.setPassword(Base64.encode(encryptedpwd));
				
		Person actualPerson = null;
		
		try 
		{
			actualPerson = personDAO.updateUser(person);
		} 
		catch(MinimumPwdLengthException min)
		{
			System.out.println(min.toString());
		}
		catch(InvalidCustomerNameException invcust)
		{
			System.out.println(invcust.toString());
		}
		catch(ServiceUnavailableException servunavl)
		{
			System.out.println(servunavl.toString());
		}
		
		Assert.assertEquals("Test", actualPerson.getFirstName());		
		Assert.assertEquals("Create", actualPerson.getLastName());
	}
	
	@Test
	public void updateUser_1() throws Exception
	{
		//testing for password validity
		Person person = new Person();
		person.setCustomerType("P");
		person.setFirstName("Guest");
		person.setLastName("User");
		person.setAddress("Unknown");
		person.setState("CA1");
		person.setCity("SJ1");
		person.setZipCode(95035);
		person.setEmailId("test@gm.com");
		PersonDAO personDAO = new PersonDAO();
		PersonBussiness personBI = new PersonBussiness();
		byte[] encryptedpwd = personBI.encryptPassword("@@@@@");
		person.setPassword(Base64.encode(encryptedpwd));
				
		Person actualPerson = null;
		
		try 
		{
			actualPerson = personDAO.updateUser(person);
		} 
		catch(MinimumPwdLengthException min)
		{
			System.out.println(min.toString());
		}
		catch(InvalidCustomerNameException invcust)
		{
			System.out.println(invcust.toString());
		}
		catch(ServiceUnavailableException servunavl)
		{
			System.out.println(servunavl.toString());
		}
	}
	
	@Test
	public void updateUser_2() throws Exception
	{
		//checking user first name
		Person person = new Person();
		person.setCustomerType("P");
		person.setFirstName("9#4dgfd");
		person.setLastName("User");
		person.setAddress("Unknown");
		person.setState("CA1");
		person.setCity("SJ1");
		person.setZipCode(95035);
		person.setEmailId("test9@gm.com");
		PersonDAO personDAO = new PersonDAO();
		PersonBussiness personBI = new PersonBussiness();
		byte[] encryptedpwd = personBI.encryptPassword("guest123");
		person.setPassword(Base64.encode(encryptedpwd));
				
		Person actualPerson = null;
		
		try 
		{
			actualPerson = personDAO.updateUser(person);
		} 
		catch(MinimumPwdLengthException min)
		{
			System.out.println(min.toString());
		}
		catch(InvalidCustomerNameException invcust)
		{
			System.out.println(invcust.toString());
		}
		catch(ServiceUnavailableException servunavl)
		{
			System.out.println(servunavl.toString());
		}
	}
	
	@Test
	public void updateUser_3() throws Exception
	{
		//checking user first name 
		Person person = new Person();
		person.setCustomerType("P");
		person.setFirstName("iammorethantwentycharecterslong");
		person.setLastName("User");
		person.setAddress("Unknown");
		person.setState("CA1");
		person.setCity("SJ1");
		person.setZipCode(95035);
		person.setEmailId("test10@gm.com");
		PersonDAO personDAO = new PersonDAO();
		PersonBussiness personBI = new PersonBussiness();
		byte[] encryptedpwd = personBI.encryptPassword("guest123");
		person.setPassword(Base64.encode(encryptedpwd));
			
		Person actualPerson = null;
		
		try 
		{
			actualPerson = personDAO.updateUser(person);
		} 
		catch(MinimumPwdLengthException min)
		{
			System.out.println(min.toString());
		}
		catch(InvalidCustomerNameException invcust)
		{
			System.out.println(invcust.toString());
		}
		catch(ServiceUnavailableException servunavl)
		{
			System.out.println(servunavl.toString());
		}
	}
	
	
	@Test
	public void updateUser_4() throws Exception
	{
		//checking user last name 
		Person person = new Person();
		person.setCustomerType("P");
		person.setFirstName("Guest");
		person.setLastName("U76##");
		person.setAddress("Unknown");
		person.setState("CA1");
		person.setCity("SJ1");
		person.setZipCode(95035);
		person.setEmailId("test10@gm.com");
		PersonDAO personDAO = new PersonDAO();
		PersonBussiness personBI = new PersonBussiness();
		byte[] encryptedpwd = personBI.encryptPassword("guest123");
		person.setPassword(Base64.encode(encryptedpwd));
			
		Person actualPerson = null;
		
		try 
		{
			actualPerson = personDAO.updateUser(person);
		} 
		catch(MinimumPwdLengthException min)
		{
			System.out.println(min.toString());
		}
		catch(InvalidCustomerNameException invcust)
		{
			System.out.println(invcust.toString());
		}
		catch(ServiceUnavailableException servunavl)
		{
			System.out.println(servunavl.toString());
		}
	}
	
	@Test
	public void updateUser_5() throws Exception
	{
		//checking user last name 
		Person person = new Person();
		person.setCustomerType("P");
		person.setFirstName("Guest");
		person.setLastName("iammorethantwentycharecterslong");
		person.setAddress("Unknown");
		person.setState("CA1");
		person.setCity("SJ1");
		person.setZipCode(95035);
		person.setEmailId("test10@gm.com");
		PersonDAO personDAO = new PersonDAO();
		PersonBussiness personBI = new PersonBussiness();

		byte[] encryptedpwd = personBI.encryptPassword("guest123");
		person.setPassword(Base64.encode(encryptedpwd));
			
		Person actualPerson = null;
		
		try 
		{
			actualPerson = personDAO.updateUser(person);
		} 
		catch(MinimumPwdLengthException min)
		{
			System.out.println(min.toString());
		}
		catch(InvalidCustomerNameException invcust)
		{
			System.out.println(invcust.toString());
		}
		catch(ServiceUnavailableException servunavl)
		{
			System.out.println(servunavl.toString());
		}
	}
	
	@Test
	public void updateUser_6() throws Exception
	{
		//checking user email 
		Person person = new Person();
		person.setCustomerType("P");
		person.setFirstName("Guest");
		person.setLastName("User");
		person.setAddress("Unknown");
		person.setState("CA1");
		person.setCity("SJ1");
		person.setZipCode(95035);
		person.setEmailId("test6gm.com");
		PersonDAO personDAO = new PersonDAO();
		PersonBussiness personBI = new PersonBussiness();
		byte[] encryptedpwd = personBI.encryptPassword("guest123");
		person.setPassword(Base64.encode(encryptedpwd));
		
		//personBI.createUser(person);
		
		Person actualPerson = null;
		
		try 
		{
			actualPerson = personDAO.updateUser(person);
		} 
		catch(MinimumPwdLengthException min)
		{
			System.out.println(min.toString());
		}
		catch(InvalidCustomerNameException invcust)
		{
			System.out.println(invcust.toString());
		}
		catch(ServiceUnavailableException servunavl)
		{
			System.out.println(servunavl.toString());
		}
	}
	
	@Test
	public void updateUser_7() throws Exception
	{
		//checking password validity 
		Person person = new Person();
		person.setCustomerType("P");
		person.setFirstName("Guest");
		person.setLastName("User");
		person.setAddress("Unknown");
		person.setState("CA1");
		person.setCity("SJ1");
		person.setZipCode(95035);
		person.setEmailId("test6@gm.com");
		PersonDAO personDAO = new PersonDAO();
		PersonBussiness personBI = new PersonBussiness();
		byte[] encryptedpwd = personBI.encryptPassword("123451234512345");
		person.setPassword(Base64.encode(encryptedpwd));
		
		//personBI.createUser(person);
		
		Person actualPerson = null;
		
		try 
		{
			actualPerson = personDAO.createUser(person);
		} 
		catch(MinimumPwdLengthException min)
		{
			System.out.println(min.toString());
		}
		catch(InvalidCustomerNameException invcust)
		{
			System.out.println(invcust.toString());
		}
		catch(ServiceUnavailableException servunavl)
		{
			System.out.println(servunavl.toString());
		}
	}

	@Test
	public void removeUser() throws Exception
	{
		//valid input check
		PersonDAO personDAO = new PersonDAO();
		int success = 0;
		String emailId = "test100@gmail.com";
		try
		{
			success = personDAO.removeUser(emailId);
		}
		catch(UserException user)
		{
			System.out.println(user.toString());
		}
		catch(DeleteCustomerWithOutstandingMovieException delcust)
		{
			System.out.println(delcust.toString());
		}
		catch(ServiceUnavailableException servunavl)
		{
			System.out.println(servunavl.toString());
		}
		
		Assert.assertEquals(1,success);
	}
	
	@Test
	public void removeUser_1() throws Exception
	{
		//invalid input check
		PersonDAO personDAO = new PersonDAO();
		int success = 0;
		String emailId = "test90@gmail.com";
		try
		{
			success = personDAO.removeUser(emailId);
		}
		catch(UserException user)
		{
			System.out.println(user.toString());
		}
		catch(DeleteCustomerWithOutstandingMovieException delcust)
		{
			System.out.println(delcust.toString());
		}
		catch(ServiceUnavailableException servunavl)
		{
			System.out.println(servunavl.toString());
		}		
		Assert.assertEquals(0,success);

	}
	
	@Test
	public void customerorder() throws Exception
	{
		//valid input 		
		long memshipid=100000001;
		PersonDAO personDAO = new PersonDAO();
		Movie[] movie = null;
		
		try
		{
			movie = personDAO.customerorder(memshipid);
		}
		catch(ServiceUnavailableException servunavl)
		{
			System.out.println(servunavl.toString());	
		}	
		if(movie != null)
		{
		for (int i=0;i < movie.length ; i++)
		{
			System.out.println("Movie " + (i+1) +": details");
			System.out.println("Movie Name: " +movie[i].getMovieName());
			System.out.println("Movie Rating: " +movie[i].getRating());
			System.out.println("Movie Rent Date: " +movie[i].getRentdate());
			System.out.println("Movie Rent Amount: " +movie[i].getRentamount());
			System.out.println("Movie Banner: " +movie[i].getMovieBanner());
			System.out.println("Category Name: " +movie[i].getCategoryname());
		}
		}
		else
			System.out.println("No movies in order table");
	}
	
	@Test
	public void customerorder_1() throws Exception
	{
		//invalid input 	
		long memshipid=1000001;
		PersonDAO personDAO = new PersonDAO();
		Movie[] movie = null;
		try
		{
			movie = personDAO.customerorder(memshipid);
		}
		catch(ServiceUnavailableException servunavl)
		{
			System.out.println(servunavl.toString());	
		}	
		if(movie != null)
		{
		for (int i=0;i < movie.length ; i++)
		{
			System.out.println("Movie " + (i+1) +": details");
			System.out.println("Movie Name: " +movie[i].getMovieName());
			System.out.println("Movie Rating: " +movie[i].getRating());
			System.out.println("Movie Rent Date: " +movie[i].getRentdate());
			System.out.println("Movie Rent Amount: " +movie[i].getRentamount());
			System.out.println("Movie Banner: " +movie[i].getMovieBanner());
			System.out.println("Category Name: " +movie[i].getCategoryname());
		}
		}
		else
			System.out.println("No movies in order table");
	}
	@Test
	public void customerqueue() throws Exception
	{
		//valid input 
		long memshipid=100000001;
		PersonDAO personDAO = new PersonDAO();
		Movie[] movie = null;
		try
		{
			movie = personDAO.customerqueue(memshipid);
		}
		catch(ServiceUnavailableException servunavl)
		{
			System.out.println(servunavl.toString());	
		}
		catch(UserCartIsEmptyException empty)
		{
			System.out.println(empty.toString());
		}
		for (int i=0;i < movie.length ; i++)
		{
			System.out.println("Movie " + (i+1) +": details");
			System.out.println("Movie Name: " +movie[i].getMovieName());
			System.out.println("Movie Rating: " +movie[i].getRating());
			System.out.println("Movie Banner: " +movie[i].getMovieBanner());
			System.out.println("Category Name: " +movie[i].getCategoryname());
		}
	}
	
	@Test
	public void customerqueue_1() throws Exception
	{
		//invalid input 	
		long memshipid=1000001;
		PersonDAO personDAO = new PersonDAO();
		Movie[] movie = null;
		try
		{
			movie = personDAO.customerqueue(memshipid);
		}
		catch(ServiceUnavailableException servunavl)
		{
			System.out.println(servunavl.toString());	
		}
		catch(UserCartIsEmptyException empty)
		{
			System.out.println(empty.toString());
		}
		
		for (int i=0;i < movie.length ; i++)
		{
			System.out.println("Movie " + (i+1) +": details");
			System.out.println("Movie Name: " +movie[i].getMovieName());
			System.out.println("Movie Rating: " +movie[i].getRating());
			System.out.println("Movie Banner: " +movie[i].getMovieBanner());
			System.out.println("Category Name: " +movie[i].getCategoryname());
		}
	}
	
	@Test
	public void addtoQueue() 
	{
		//valid input 
		
		long memshipid=100000001;
		int movieid = 8;
		PersonDAO personDAO = new PersonDAO();
		int success=0;
 		try
		{
			success = personDAO.addtoQueue(movieid,memshipid);
		}
 		catch(ServiceUnavailableException servunavl)
		{
 			System.out.println(servunavl.toString());	
		}	
 		catch(MovieAlreadyExistsException empty)
		{
 			System.out.println(empty.toString());
		}
 		Assert.assertEquals(1,success);
	}
	@Test
	public void addtoQueue_1() 
	{
		//invalid input - passing the same movie to add again
		long memshipid=100000001;
		int movieid = 8;
		PersonDAO personDAO = new PersonDAO();
		int success=0;
 		try
		{
			success = personDAO.addtoQueue(movieid,memshipid);
		}
 		catch(ServiceUnavailableException servunavl)
		{
 			System.out.println(servunavl.toString());	
		}	
 		catch(MovieAlreadyExistsException empty)
		{
 			System.out.println(empty.toString());
		}
 		Assert.assertEquals(0,success);
	}
	
	@Test
	public void removefromQueue() 
	{
		//invalid input - passing the same movie to remove again
		
		long memshipid=100000001;
		int movieid = 8;
		PersonDAO personDAO = new PersonDAO();
		int success=0;
 		try
		{
			success = personDAO.removefromQueue(movieid,memshipid);
		}
 		catch(ServiceUnavailableException servunavl)
		{
 			System.out.println(servunavl.toString());	
		}	
 		catch(MovieAlreadyDeletedException empty)
		{
 			System.out.println(empty.toString());
		}
 		Assert.assertEquals(1,success);
	}
	
	@Test
	public void removefromQueue_1() 
	{
		//invalid input - passing the same movie to remove again
		
		long memshipid=100000001;
		int movieid = 8;
		PersonDAO personDAO = new PersonDAO();
		int success=0;
 		try
		{
			success = personDAO.removefromQueue(movieid,memshipid);
		}
 		catch(ServiceUnavailableException servunavl)
		{
 			System.out.println(servunavl.toString());	
		}	
 		catch(MovieAlreadyDeletedException empty)
		{
 			System.out.println(empty.toString());
		}
 		Assert.assertEquals(0,success);
	}
}
